from common.variables import consider_bfnames, consider_symbols, TimeFrameType
from datetime import datetime
from trade.data.add_factors import add_batch_factors_dag, send_factor_kafka_message
from trade.watch.kafka_watcher import KafkaWatcherKline


def main():
    timeframe: TimeFrameType = "1m"
    watcher = KafkaWatcherKline(timeframe, "kline_trigger_factor")
    for xt in watcher.watch_batch_symbols(consider_symbols):
        add_batch_factors_dag(
            consider_bfnames,
            [],
            consider_symbols,
            start=datetime.fromtimestamp(xt).isoformat(),
            end=datetime.fromtimestamp(xt + 1).isoformat(),
            timeframe=timeframe,
            max_part=1000,
            n_jobs=6,
            verbose=10,
            callback=send_factor_kafka_message,
        )


if __name__ == "__main__":
    main()
